﻿#include "testcontroller.h"
#include <QDebug>
#include <QJsonObject>
#include <QJsonDocument>
#include <QThread>

void TestController::registerRoutes(QHttpServer &server)
{
    // 测试
    qDebug() << "注册";
    server.route("/",[this](){
        return hello();
    });
}


QHttpServerResponse TestController::hello()
{
    qDebug() << QThread::currentThreadId();
    return QString("Hello, World! -- %1").arg(QString::number(int(QThread::currentThreadId())));
//    QJsonObject obj;
//    obj["message"] = "Hello, World!";
//    return QHttpServerResponse(QJsonDocument(obj).toJson());
}
